package com.jump.userweb.service;

import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by fangxiao on 15/9/8.
 */

@Service
public class UserService {

    public final static  String USER_URL_V1 = "http://localhost:8080/user/v1";


    public Map getRegisterMap(String userName, String password, String mobile, String email) {
        Map params = new HashMap();
        params.put("username", userName);
        params.put("password", password);
        params.put("mobile", mobile);
        params.put("email", email);
        RestTemplate rs = new RestTemplate();
        Map map = (Map)rs.postForObject(USER_URL_V1+"/register", params, Map.class);
        return map;
    }


    public Map getLoginMap(String info, String password) {
        Map params = new HashMap();
        params.put("info", info);
        params.put("password", password);
        RestTemplate rs = new RestTemplate();
        Map map = (Map)rs.postForObject(USER_URL_V1+"/login", params, Map.class);
        return map;

    }

    public Map getCertificationMap(String userName, String chineseName, String idCard) {
        Map params = new HashMap();
        params.put("userName", userName);
        params.put("chineseName", chineseName);
        params.put("idCard", idCard);
        RestTemplate rs = new RestTemplate();
        Map map = (Map)rs.postForObject(USER_URL_V1+"/certification", params, Map.class);
        return map;
    }

}
